package com.kasax.skin.support.corel;

import android.content.Context;
import android.content.SharedPreferences;

public class SkinReference {
    private static final String KEY_NAME_SP = "sp_skin2_config";
    private static final String KEY_NAME_SKIN = "key_skin2_path";
    private static SkinReference instance;
    private static SharedPreferences preferences;

    private SkinReference() {

    }

    private SkinReference(Context context) {
        preferences = context.getSharedPreferences(KEY_NAME_SP, Context.MODE_PRIVATE);
    }

    public static void init(Context context) {
        if (instance == null) {
            synchronized (SkinReference.class) {
                if (instance == null) {
                    instance = new SkinReference(context);
                }
            }
        }
    }

    public static SkinReference getInstance() {
        return instance;
    }

    public void setSkin(String path) {
        preferences.edit().putString(KEY_NAME_SKIN, path).apply();
    }

    public String getSkin() {
        return preferences.getString(KEY_NAME_SKIN, null);
    }
}
